package com.bayihouse.excel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import jnr.ffi.annotations.In;

import java.util.HashMap;
import java.util.Map;

public class CategoryConverter implements Converter<Integer> {
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    private static Map<String, Integer> roomMap = new HashMap<>();

    static {
        roomMap.put("楼房", 0);
        roomMap.put("商品房", 1);
        roomMap.put("其他", 3);
    }


    public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty,
                                     GlobalConfiguration globalConfiguration) {
        String categoryStr = cellData.getStringValue();
        return roomMap.get(categoryStr);
    }
}
